package com.woniuxy.his.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.woniuxy.his.common.Result;
import com.woniuxy.his.service.IPayService;
import com.woniuxy.his.vo.PayOfCheckVo;
import com.woniuxy.his.vo.PayOfPrescriptionVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

@RestController
@Slf4j
@CrossOrigin("*")
public class PayController {

    @Resource
    private IPayService payService;

    @GetMapping("getAllPrescriptionPayMassage")
    public Result getAllPrescriptionPayMassage(String startTime, String stopTime, @RequestParam(name = "current", defaultValue = "1") Integer current, @RequestParam(name = "pageSize", defaultValue = "3") Integer pageSize) throws ParseException {
        log.info("起始时间{}，结束时间{}，当前页{}，,页容量{}", startTime, stopTime, current, pageSize);
        DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date time1 = sdf.parse(startTime);
        Date time2 = sdf.parse(stopTime);
        IPage<PayOfPrescriptionVo> allPayMassage = payService.getAllPrescriptionPayMassage(current, pageSize, time1, time2);
        return Result.success("20000","success",allPayMassage);
    }

    @GetMapping("getAllCheckPayMassage")
    public Result getAllCheckPayMassage(String startTime, String stopTime, @RequestParam(name = "current", defaultValue = "1") Integer current, @RequestParam(name = "pageSize", defaultValue = "3") Integer pageSize) throws ParseException {
        log.info("起始时间{}，结束时间{}，当前页{}，,页容量{}", startTime, stopTime, current, pageSize);
        DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date time1 = sdf.parse(startTime);
        Date time2 = sdf.parse(stopTime);
        IPage<PayOfCheckVo> allPayMassage = payService.getAllCheckPayMassage(current, pageSize, time1, time2);
        return Result.success("20000","success",allPayMassage);
    }

}
